
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title> 地理信息编辑 </title>
    <link rel="stylesheet" type="text/css" href="/css/style.css" />

    <style type="text/css">
        *, body {
            margin: 0px;
            font-family: '微软雅黑';
        }
    </style>
    <script src="~/js/jquery-1.10.2.min.js"></script>
    <script src="~/js/jquery.form.js"></script>
    <script src="~/js/generic.js"></script>
</head>

<body>

@Html.Partial("top")

<table class="maintable">
    <tr>
        @Html.Partial("menu")
        <td class="rightmaintd" valign="top">
            <div class="searchdiv">
                <a href="/dlxx/list">&lt; 返回</a>
                <div class="rightsearchdiv"><!-- name --></div>
            </div>
            <table class="leftrighttable" border="0">
                <tr>
                    <td class="lefttdtable" width="50%" valign="top">
                        <table cellpadding="6">
                            <tr>
                                <td class="tdname">省</td>
                                <td><input type="text" id="sheng" class="textinput" maxlength="50"></td>
                            </tr>
                            <tr>
                                <td class="tdname">市/县</td>
                                <td><input type="text" id="shi" class="textinput" maxlength="50"></td>
                            </tr>
                            <tr>
                                <td class="tdname">地域</td>
                                <td><input type="text" id="diyu" class="textinput" maxlength="50"></td>
                            </tr>

                            <tr>
                                <td class="tdname">流域</td>
                                <td><input type="text" id="liuyu" class="textinput" maxlength="50"></td>
                            </tr>

                        </table>
                    </td>
                    <td class="righttdtable" width="50%" valign="top"></td>
                </tr>

            </table>

            <div class="shenhediv">
                <input type="button" value="保 &nbsp; &nbsp; 存" class="baocunbtn" onclick="saveInfo()">
                <input type="button" value="审核通过" style="display: none;" id="btnValidate" class="shenhebtn" onclick="validate();"> &nbsp;&nbsp;
                <span id="lrxx"></span>
            </div>

        </td>
    </tr>
</table>

@Html.Partial("bottom")

</body>
</html>
<script type="text/javascript">
    var usertype = "@type";
    var _app_guid = '@ViewBag.Guid';
    var _app_edit = '@ViewBag.EditState';
    var submit = true;
    $(document).ready(function() {
        if ((usertype == "管理员" || usertype == "审核者") && _app_edit == "edit") {
            $("#btnValidate").show();
        }
        if (_app_edit == "edit") {
            util.getJSON("/dlxx/Get", { "id": _app_guid }, function (json) {
                if (json.status == 0) {
                    if (json.entity.shenhe && json.entity.shenhe == "通过") {
                        $("#btnValidate").val("已通过审核");
                    }
                    $("#sheng").val(json.entity.sheng);
                    $("#shi").val(json.entity.shi);
                    $("#diyu").val(json.entity.diyu);
                    $("#liuyu").val(json.entity.liuyu);
                    $("#lrxx").html('(录入人：' + json.entity.createuser + '， 录入时间：' + util.formateDate(json.entity.createtime, "yyyy-MM-dd hh:mm:ss") + ') ');
                }
            });
            $("#divTitle").html("更新地理信息");

        } else {
            $("#divTitle").html("创建地理信息");
        }
    });

    //保存
    function saveInfo() {
        var entity = {
            "sheng": $("#sheng").val(),
            "shi": $("#shi").val(),
            "diyu": $("#diyu").val(),
            "liuyu": $("#liuyu").val()
        };
        var url = "/dlxx/Create";
        if (_app_edit == "edit") {
            url = "/dlxx/Update";
            entity.id = _app_guid;
        }

        util.postJson(url,
            {
                "entity": entity
            }, function (json) {
                if (json.status == 0) {
                    alert(json.msg);
                    location.href = "/dlxx/List";
                } else {
                    alert(json.msg);
                }
            });
    }
    function validate() {
        util.postJson("/dlxx/validate",
            {
                "id": _app_guid,
            }, function (json) {
                if (json.status == 0) {
                    alert(json.msg);
                    location.href = "/dlxx/List";
                } else {
                    alert(json.msg);
                }
            });
    }
</script>